package cn.sjx.modules.nbiot.business.impl;


import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import cn.sjx.modules.nbiot.entity.common.AckEnum;
import cn.sjx.modules.nbiot.entity.receive.IotProtocolReceive_0x20;
import cn.sjx.modules.nbiot.entity.receive.IotProtocolReceive_0x21;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Service;

/**
 * 处理具体业务
 *
 * @Author: sjx
 * @Date: 2019年09月17日 0017 19:53:33
 */
@Service("geomagneticUdpBusinessHandler")
public class GeomagneticUdpBusinessImpl extends GeomagneticUdpBusinessHandlerImpl {

    private static final Log logger = LogFactory.get();

    @Override
    public AckEnum handlerGeomagneticDataMessage(IotProtocolReceive_0x20 receiveBase, String receiveHexDataStr) throws Exception {
        // 封装发送数据
        JSONObject receiveJsonObject = new JSONObject(2);
        receiveJsonObject.put("receiveBase", (JSONObject) JSONObject.toJSON(receiveBase));
        receiveJsonObject.put("receiveHexDataStr", receiveHexDataStr);

        // todo 发送业务请求
        logger.info("======> 业务类处理普通报文-解码对象 = {}", receiveBase);
        logger.info("======> 业务类处理普通报文-未解码数据 = {}", receiveHexDataStr);

        return AckEnum.SUCCESSFUL;
    }

    @Override
    public AckEnum handlerGeomagneticHeartbeatPacket(IotProtocolReceive_0x21 receiveBase, String receiveHexDataStr) throws Exception {
        // 封装发送数据
        JSONObject receiveJsonObject = new JSONObject(2);
        receiveJsonObject.put("receiveBase", (JSONObject) JSONObject.toJSON(receiveBase));
        receiveJsonObject.put("receiveHexDataStr", receiveHexDataStr);

        // todo 发送业务请求

        logger.info("======> 业务类处理普通报文-解码对象 = {}", receiveBase);
        logger.info("======> 业务类处理普通报文-未解码数据 = {}", receiveHexDataStr);

        return AckEnum.SUCCESSFUL;
    }

}
